package com.sixth.stock.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sixth.core.entity.Comment;
import com.sixth.core.vo.R;
import com.sixth.stock.mapper.CommentMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/stock/comment")
public class CommentController {
    @Resource
    private CommentMapper commentMapper;
    //根据用户id，即医生，获取评论
    @GetMapping ("/getUserCommentById/{userId}")
    public R<List<Comment>> getUserCommentById(@PathVariable String userId){
        Integer id = Integer.parseInt(userId);
        List<Comment> commentList = commentMapper.selectList(new QueryWrapper<Comment>()
                .eq("value_id",id).eq("deleted",0).select("id","value_id","content","pic_urls","add_time","star"));
        return R.ok(commentList);
    }
}
